﻿@{
    ViewBag.Title = "添加维修";
    Layout = "~/Views/Shared/_FlowForm.cshtml";
}
<script src="~/Content/scripts/jquery/layer/jquery.js?v=1.83.min"></script>
<script src="~/Content/scripts/jquery/layer/layer.min.js"></script>
<link href="~/Content/styles/font-awesome.min.css" rel="stylesheet" />
<link href="~/Content/styles/BillDetail.css?v=1.1" rel="stylesheet" />
<link href="~/Content/styles/anitmate.css" rel="stylesheet" />
<link href="~/Content/styles/style.css" rel="stylesheet" />

<link href="~/Content/scripts/plugins/tree/tree.css" rel="stylesheet" />
<link href="~/Content/scripts/plugins/jqgrid/jqgrid.css" rel="stylesheet" />
<script src="~/Content/scripts/plugins/tree/tree.js"></script>

<script src="/Content/scripts/plugins/validator/js?v=XgpF3bkqcHESsLip2j1dhS6n2I-zHyD2VCazpanqH6Q1"></script>
<script src="/Content/scripts/utils/js?v=FNqaC7G7A87_J4VCIQpQEAO-d_2Qf2wSxoZexwRzulo1"></script>
<script src="~/Content/scripts/plugins/jqgrid/jqgrid.js"></script>
<script src="~/Content/scripts/utils/UploadFile.js"></script>
<script src="~/Content/scripts/plugins/jquery.md5.js"></script>
<script src="~/Content/scripts/plugins/uploadify/ajaxfileupload.js"></script>
<style>
    .upload_append_list {
        position: relative;
        float: left;
    }
</style>
<script>
    var keyValue = request('keyValue');
    var billDetailId = "", sourceType = request('sourceType'), sourceId = request('sourceId');
    var organizeid = "@LeSoft.Application.Code.OperatorProvider.Provider.Current().CompanyId";
    var fileFilter = [];
    var IMGData = [];
    $(function () {
        initControl();
        //计算居中位置
        var mg_top = ((parseInt($(window).height()) - parseInt($(".photo-div").height())) / 2);

        $(".photo-div").css({
            "margin-top": "" + mg_top + "px"
        });
        //关闭
        $(".photo-close").click(function () {
            $(".photo-mask").hide();
            $(".photo-panel").hide();
        });
        //下一张
        $(".photo-panel .photo-div .arrow-next").click(function () {
            img_index++;
            if (img_index >= $("#preview li img").length) {
                img_index = 0;
            }
            img_src = $("#preview li img").eq(img_index).attr("src");
            photoView($("#preview li img"));
        });
        //上一张
        $(".photo-panel .photo-div .arrow-prv").click(function () {
            img_index--;
            if (img_index < 0) {
                img_index = $("#preview li img").length - 1;
            }
            img_src = $("#preview li img").eq(img_index).attr("src");
            photoView($("#preview li img"));
        });
        //调用
        $("#preview li img").live("click", function () {
            $(".photo-mask").show();
            $(".photo-panel").show();
            img_src = $(this).attr("src");
            img_index = $(this).index();
            photoView($(this));
        });
    });
    //自适应预览
    function photoView(obj) {
        if ($(obj).width() >= $(obj).height()) {
            $(".photo-panel .photo-div .photo-img .photo-view-h").attr("class", "photo-view-w");
            $(".photo-panel .photo-div .photo-img .photo-view-w img").attr("src", img_src);
        } else {
            $(".photo-panel .photo-div .photo-img .photo-view-w").attr("class", "photo-view-h");
            $(".photo-panel .photo-div .photo-img .photo-view-h img").attr("src", img_src);
        }


    }
    //上传文件到后台
    function UploadFile(a) {
        $.ajaxFileUpload({
            url: "../../PropertyManage/CS_RepaireBill/UploadFile1",
            secureuri: false,
            fileElementId: 'fileImage' + a,
            dataType: 'json',
            success: function (data) {
                var files = document.getElementById('fileImage' + a).files;
                var arrFile = [];
                if (files.length > 0) {
                    for (var i = 0; i < files.length; i++) {
                        arrFile.push({ Type: a, Data: files[i] })
                    }
                    if (fileFilter.length > 0) {
                        for (var j = 0, fileb; fileb = fileFilter[j]; j++) {
                            arrFile.push(fileb);
                        }
                        SetFile(arrFile);
                    }
                    else {
                        SetFile(arrFile);
                    }
                }
            }

        });
    }
    //显示上传文件
    function SetFile(files) {
        fileFilter = files;
        var data1 = $.grep(files, function (value) { return value.Type == 1; });
        var data2 = $.grep(files, function (value) { return value.Type == 2; });
        if (data1.length > 4 || data2.length > 4) {
            dialogMsg("最多只能传4个附件", 0);
            return;
        }
        var _html = "<ul>";
        var _htm2 = "<ul>";
        debugger;
        for (var i = 0; i < files.length; i++) {
            if (files[i]) {
                switch (files[i]["Type"]) {
                    case 1:
                        if (files[i]["Data"].constructor.name == "File") {
                            _html += "<li><a  class='Del_Img' onclick='Del_Img(" + i + ");' title='删除' >x</a><img id='uploadImage_" + i + "' src='" + window.URL.createObjectURL(files[i]["Data"]) + "' class='" + files[i]["Data"].name + "'  /></li>";
                        }
                        else if (files[i]["Data"].constructor.name == "Object") {
                            _html += "<li><a class='Del_Img' onclick='Del_Img(" + i + ");' title='删除'>x</a><img id='uploadImage_" + i + "' src='" + files[i]["Data"].FileUrl + "'  class='" + files[i]["Data"].name + "'  /></li>";
                        }
                        break;
                    case 2:
                        if (files[i]["Data"].constructor.name == "File") {
                            _htm2 += "<li><a  class='Del_Img' onclick='Del_Img(" + i + ");' title='删除' >x</a><img id='uploadImage_" + i + "' src='" + window.URL.createObjectURL(files[i]["Data"]) + "' class='" + files[i]["Data"].name + "'  /></li>";
                        }
                        else if (files[i]["Data"].constructor.name == "Object") {
                            _htm2 += "<li><a class='Del_Img' onclick='Del_Img(" + i + ");' title='删除'>x</a><img id='uploadImage_" + i + "' src='" + files[i]["Data"].FileUrl + "'  class='" + files[i]["Data"].name + "'  /></li>";
                        }
                        break;
                    default: break;
                }
            }
        }
        _html += "</ul>"
        _htm2 += "</ul>"
        if (keyValue == "") {
            $(".IMG1").html(_html);
        }
        $(".IMG2").html(_htm2);
        debugger;

    }
    function Del_Img(s) {
        fileFilter = $.grep(fileFilter, function (value) {
            return value != fileFilter[s];
        })
        SetFile(fileFilter);
    }
    function SetFileDisplay(dataArray) {
        var _html = "<ul>";
        var _html2 = "<ul>";
        if (dataArray.length > 0) {
            //fileFilter = dataArray;
            for (var i = 0; i < dataArray.length; i++) {
                if (dataArray[i].Type == 31) {
                    _html += "<li><img id='uploadImage_" + i + "' src='" + dataArray[i].FileUrl + "'  /></li>";
                }
                if (dataArray[i].Type == 32) {
                    _html += "<li><img id='uploadImage_" + i + "' src='" + dataArray[i].FileUrl + "'  /></li>";
                }
            }
            _html += "</ul>";
            _html2 += "</ul>";
            $(".IMG1").html(_html);
            $(".IMG2").html(_html2);
        }

    }

    function GetGrid() {
        var queryJson = $("#filter-form").GetWebControls();
        queryJson["CategoryId"] = $(".profile-nav").find('li.active').attr('data-value');
        var $gridTable = $("#gridTable");
        $gridTable.jqGrid({
            url: "../../SystemManage/Log/GetPageListJson",
            postData: { queryJson: JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 137,
            autowidth: true,
            colModel: [
                { label: "主键", name: "LogId", hidden: true },
                {
                    label: "操作时间", name: "OperateTime", index: "OperateTime", width: 150, align: "left",
                    formatter: function (cellvalue, options, rowObject) {
                        return formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
                    }
                },
                { label: "操作用户", name: "OperateAccount", index: "OperateAccount", width: 150, align: "left" },
                { label: "IP地址", name: "IPAddress", index: "IPAddress", width: 150, align: "left" },
                { label: "系统功能", name: "Module", index: "Module", width: 150, align: "left" },
                { label: "操作类型", name: "OperateType", index: "OperateType", width: 70, align: "center" },
                {
                    label: "执行结果", name: "ExecuteResult", index: "ExecuteResult", width: 70, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == '1') {
                            return "<span class=\"label label-success\">成功</span>";
                        } else {
                            return "<span class=\"label label-danger\">失败</span>";
                        }
                    }
                },
                { label: "执行结果描述", name: "ExecuteResultJson", index: "ExecuteResultJson", width: 100, align: "left" }
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100, 500, 1000],
            pager: "#gridPager",
            sortname: 'OperateTime desc',
            rownumbers: true,
            shrinkToFit: false,
            gridview: true
        });

        //查询点击事件
        $("#btn_Search").click(function () {
            var queryJson = $("#filter-form").GetWebControls();
            queryJson["CategoryId"] = $(".profile-nav").find('li.active').attr('data-value');
            $("#gridTable").jqGrid('setGridParam', {
                url: "../../SystemManage/Log/GetPageListJson",
                postData: { queryJson: JSON.stringify(queryJson) },
                page: 1
            }).trigger('reloadGrid');
        });
    }
    function initControl() {
        var Mode = "@ViewBag.Mode";
        if (Mode == "True") {
            $("#Code").attr("placeholder", "系统已启用自动编号").attr("disabled", "disabled");
        } else {
            $("#Code").attr("isvalid", "yes").attr("checkexpession", "NotNull").attr("placeholder", "请输入编号");
        }

        $("#OrganizeId").ComboBoxTree({
            url: "../../BaseManage/Organize/GetTreeJson",
            description: "==请选择所属机构==",
            height: "250px",
            click: function (data) {
                organizeid = data.id;
            }
        });
        if (organizeid != "") $("#OrganizeId").ComboBoxTreeSetValue(organizeid);

        $("#Range").ComboBox({
            data: [{ "key": 1, "value": "客户区域" }, { "key": 2, "value": "公共区域" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            click: function (e) {
                if (e.attr('data-value') == 2) {
                    $("#CustomerId").removeAttr("isvalid").removeAttr("checkexpession").attr("disabled", "disabled");
                }
                else {
                    $("#CustomerId").attr("isvalid", "yes").attr("checkexpession", "NotNull").removeAttr("disabled", "disabled");
                }
                $("#PStructId").removeAttr("title").val("");
                $("#CustomerId").removeAttr("title").val("");
                $("#RepairMan").removeAttr("title").val("");
                $("#TellPhone").removeAttr("title").val("");
            }
        });
        $("#Range").ComboBoxSetValue(1);

        $("#Kind ").ComboBox({
            data: [{ "key": 1, "value": "有偿维修" }, { "key": 2, "value": "无偿维修" }],
            id: "key",
            text: "value",
            description: "==请选择=="
        });
        $("#Kind").ComboBoxSetValue(2);
        //维修专业
        $("#Major").ComboBoxTree({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson",
            param: { EnCode: "RepairMajor" },
            description: "==请选择==",
            height: "200px"
        });
        $("#RepairWay").ComboBox({
            data: [{ "key": 1, "value": "电话报修" }, { "key": 2, "value": "App报修" }, { "key": 3, "value": "微信报修" }, { "key": 0, "value": "其他" }],
            id: "key",
            text: "value",
            description: "==请选择=="
        });
        $("#RepairWay").ComboBoxSetValue(0);

        $("#IsAdvanceNote ").ComboBox({
            data: [{ "key": 1, "value": "是" }, { "key": 0, "value": "否" }],
            id: "key",
            text: "value",
            description: "==请选择=="
        });

        $("#SendWay").ComboBox({
            data: [{ "key": 5, "value": "人工线下派单" }, { "key": 1, "value": "派给派单人" }, { "key": 2, "value": "派给维修人" }],//, { "key": 3, "value": "发起维修人抢单" }, { "key": 4, "value": "发起派单人抢单" }
            id: "key",
            text: "value",
            description: null,
            click: function (e) {
                if (e.attr('data-value') != 5) {
                    $("#TrWay").removeAttr("hidden");
                    $(".completetr").attr("disabled", "disabled");

                    $("#Person").removeAttr("disabled");

                }
                else {
                    $("#TrWay").attr("hidden", "hidden");
                    $(".completetr").removeAttr("disabled");
                }

                if (e.attr('data-value') == 2) {
                    $("#RepairedWay input").removeAttr("disabled");
                } else {
                    $("#RepairedWay input").attr("disabled", "disabled");
                }
            }
        });
        $("#SendWay").ComboBoxSetValue(5);
        $(".completetr").removeAttr("disabled");
        $("#State").ComboBox({
            data: [{ "key": 1, "value": "未处理" }, { "key": 2, "value": "受理中" }, { "key": 3, "value": "派单中" }, { "key": 4, "value": "处理中" }, { "key": 5, "value": "已完成未回访" }, { "key": 6, "value": "已完成已回访" }, { "key": 7, "value": "已取消" }],
            id: "key",
            text: "value",
            description: "==请选择=="
        });
        $("#State").ComboBoxSetValue(1);
        $(".returnclass").attr("disabled", "disabled");
        //$("#ReturnPerson").next().children().removeAttr("onclick");
        $('#IsReturnBack').change(function (e) {
            if ($('#IsReturnBack').is(':checked')) {
                $("#ReturnPerson").removeAttr("disabled").next().children().removeAttr("disabled");
            }
            else {
                $("#ReturnPerson").attr("disabled", "disabled").next().children().attr("disabled", "disabled");
            }
        });
        $('#IsSubscribe').change(function (e) {
            if ($('#IsSubscribe').is(':checked')) {
                $("#SubscribeDate").parent().removeAttr("hidden").prev().removeAttr("hidden");
            }
            else {
                $("#SubscribeDate").parent().attr("hidden", "hidden").prev().attr("hidden", "hidden");
            }
        });

        if (!!sourceId) {
            $.SetForm({
                url: "../../PropertyManage/CS_LinkBill/GetFormJson",
                param: { keyValue: sourceId },
                success: function (data) {
                    $("#OrganizeId").ComboBoxTreeSetValue(data.data1.OrganizeId);
                    $("#PStructId").val(data.data1.Location);
                    $("#PStructId").attr("title", data.data1.PStructId);
                    $("#CustomerId").val(data.data1.CustomerName);
                    $("#CustomerId").attr("title", data.data1.CustomerId);
                    $("#RepairMan").val(data.data1.LinkMan).attr("title", data.data1.LinkManId);
                    $("#TellPhone").val(data.data1.LinkPhone);
                    $("#RepairContent").val(data.data1.LinkContent);
                    $("#wizard-actions").removeAttr("hidden");
                    $("#State").ComboBoxSetValue(2);
                }
            });
        }
        if (!!keyValue) {
            $("#fileImage1").attr("disabled", "disabled");
            $.SetForm({
                url: "../../PropertyManage/CS_RepaireBill/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#BaseInfo").SetWebControls(data.data1);
                    $("#PStructId").val(data.data1.Location);
                    $("#PStructId").attr("title", data.data1.PStructId);
                    $("#CustomerId").val(data.data1.CustomerName);
                    $("#CustomerId").attr('title', data.data1.CustomerId);
                    if (!!data.data2) {
                        $("#BaseInfo").SetWebControls(data.data2);
                        $("#ExpandInfo").SetWebControls(data.data2);
                        $("#Person").val(data.data2.RepairedMan != "" ? data.data2.RepairedMan : data.data2.SendMan);
                        $("#SendWay").ComboBoxSetValue(data.data2.SendWay);
                        billDetailId = data.data2.RepairDetailId;
                        if (data.data2.RepairedWay == 1) {
                            $("#RepairedWay input[value=1]").attr("checked", "checked");
                        } else { $("#RepairedWay input[value=2]").attr("checked", "checked"); }
                    }
                    sourceId = data.data1.SourceId;
                    sourceType = data.data1.SourceType;
                    if (data.data1.IsSubscribe == 1) $("#SubscribeDate").parent().removeAttr("hidden").prev().removeAttr("hidden");
                    SetFileDisplay(data.data3);
                    $("#State").attr('disabled', 'disabled');
                    if (data.data1.State > 1) {
                        $(".BaseClass").attr('disabled', 'disabled');
                        $("#SendWay").attr('disabled', 'disabled');
                        if (data.IsSendWay && data.data2.SendWay == 1) {
                            $("#SendWay").removeAttr("disabled");//派工方式
                            $("#SendWay").ComboBox({
                                data: [{ "key": 1, "value": "派给派单人" }, { "key": 2, "value": "派给维修人" }],
                                id: "key",
                                text: "value",
                                description: null
                            });
                            $("#SendWay").ComboBoxSetValue(1);
                        }

                        if (data.data1.IsReturnBack == 1) {
                            $("#IsReturnBack").attr("checked", "checked").attr("disabled", "disabled");
                            if (data.data1.State == 5 && data.IsReturn) {
                                $("#IsReturnBack").removeAttr("disabled");
                                $(".returnclass").removeAttr("disabled");
                            }
                        }
                    }
                    if (data.data1.State >= 4) {
                        $(".SendClass").attr('disabled', 'disabled');
                        if (data.data1.State == 4 && data.IsDispose) {
                            $("#ExpandInfo .completetr").removeAttr("disabled");
                            $("#Person").removeAttr("disabled").next().children().removeAttr("disabled");
                        }
                    }
                    if (data.data1.State >= 5) {
                        $(".completetr").attr('disabled', 'disabled');
                        $("#fileImage2").attr("disabled");
                        if (data.IsDispose) $("#ExpandInfo .completetr").removeAttr("disabled");
                        $("#Person").attr("disabled", "disabled").next().children().attr("disabled", "disabled");
                    }
                }

            });
        }
    }

    //操作记录
    function getOperateGrid() {
        $gridTable = $("#gridTable_Operate");
        $gridTable.jqGrid({
            url: "../../SystemManage/Setting/GetOperateRecordList",
            postData: { BillId: keyValue },
            datatype: "json",
            height: 650,
            hidegrid: false,
            caption: "操作记录",
            autowidth: true,
            colModel: [
               { label: '项目主键', name: 'Id', hidden: true },
                        { label: '业务类别', name: 'Type', width: 100, align: 'center', sortable: false },
                        { label: '操作人', name: 'FromOperateName', width: 100, align: 'center', sortable: false },
                        { label: '操作时间', name: 'Date', width: 170, align: 'center', sortable: false },
                        {
                            label: "操作内容", name: "Content", index: "Content", width: 590, align: "left", sortable: false,
                            formatter: function (cellvalue, options, rowObject) {
                                if (!!rowObject.ToOperateName)
                                    return "发起者：" + rowObject.FromOperateName + "，接受者：" + rowObject.ToOperateName + "<br/>" + cellvalue;
                                else
                                    return "发起者：" + rowObject.FromOperateName + "<br/>" + cellvalue;
                            }
                        },
            ],
            viewrecords: true,
            rownumbers: true,

        });
    }
    //保存表单
    function AcceptClick() {
        if (!$('#BaseInfo').Validform()) {
            return false;
        }
        if (!$("#Date").val()) { dialogMsg("单据时间不允许为空", 0); return false; }
        var postData = $("#form1").GetWebControls(keyValue);
        postData["PStructId"] = $("#PStructId").attr('title');
        postData["Location"] = $("#PStructId").val();
        postData["SourceType"] = !!sourceType ? sourceType : 0;
        postData["SourceId"] = sourceId;
        var radiodbtns = document.getElementsByName("IsSendMessage");
        for (var i = 0; i < radiodbtns.length; i++) {
            if (radiodbtns[i].checked)
                postData["IsSendMessage"] = radiodbtns[i].value;
        }
        postData["RepairManId"] = $("#RepairMan").attr("title");
        postData["RepairBillId"] = keyValue;
        postData["RepairDetailId"] = billDetailId;
        postData["CustomerId"] = $("#CustomerId").attr("title");
        postData["CustomerName"] = $("#CustomerId").val();
        if (postData["SendWay"] == 1) {
            //派给派单人
            postData["SendManId"] = $("#Person").attr("title");
            postData["SendMan"] = postData["Person"];
        }
        else if (postData["SendWay"] == 2) {
            //派给维修人
            postData["ReceivedMan"] = postData["Person"];
            postData["ReceivedManId"] = $("#Person").attr("title");
            postData["SendManId"] = "@LeSoft.Application.Code.OperatorProvider.Provider.Current().UserId";
            postData["SendMan"] = "@LeSoft.Application.Code.OperatorProvider.Provider.Current().UserName";
            postData["SendDate"] = "@LeSoft.Util.Time.Now.Date";
        }
        if (postData["ReceivedMan"] != "") {
            postData["RepairedMan"] = postData["ReceivedMan"]
        }

        postData["State"] = $("#State").attr('data-value');
        postData["IsReturnBack"] = $("#IsReturnBack").attr("checked") == "checked" ? 1 : 0;
        postData["RepairedWay"] = $("input[name=RepairedWay][checked=checked]").val();
        if (postData["IsReturnBack"] == 1) {
            postData["ReturnBackName"] = $("#ReturnPerson").val();
            postData["ReturnBackManId"] = $("#ReturnPerson").attr("title");
        }
        var ImgData = [];
        for (var i = 0; i < fileFilter.length; i++) {
            ImgData.push({
                Type: fileFilter[i]["Type"],
                Name: fileFilter[i]["Data"].name
            })
        }
        $.SaveForm({
            url: "../../PropertyManage/CS_RepaireBill/SaveFormTest?keyValue=" + keyValue + "&IMG=" + JSON.stringify(ImgData),
            param: postData,
            loading: "正在保存数据...",
            success: function (data) {
                $.currentIframe().$("#gridTable").resetSelection();
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }

    function DataItemSelect(type, obj) {

        if ($("#OrganizeId").attr('data-value') == undefined) {
            dialogMsg("请先选择机构", 0);
        } else {
            if (!!$(obj).attr("disabled")) { return false; }
            var options = {};
            switch (type) {
                case 1: {
                    var _type = 1;
                    if ($("#Range").attr("data-value") == 2) { _type = 2; }
                    var data = [{ id: "PStructId", text: "", value: "" }, { id: "CustomerId", text: "", value: "" }, { id: "RepairMan", text: "", value: "" }, { id: "TellPhone", text: "", value: "" }];
                    options = {
                        category: 3,
                        type: _type,
                        organizeid: $("#OrganizeId").attr('data-value'),
                        data: data
                    };
                }; break;
                case 2: {
                    debugger;
                    var type = $('#RepairedWay input[name="RepairedWay"]:checked ').val();//== 1 ? 3 : 6;//处理方式
                    var sendway = $('#SendWay').attr('data-value');//1-派单人 2-处理人
                    var category = sendway != "" && sendway == 1 ? 11 : type == 1 ? 12 : 13;
                    var data = [{ id: "Person", text: "", value: "" }];
                    options = {
                        category: category,
                        type: 3,
                        organizeid: $("#OrganizeId").attr('data-value'),
                        data: data
                    };

                }; break;
                case 3: {
                    //回访人
                    var data = [{ id: "ReturnPerson", text: "", value: "" }];
                    options = {
                        category: 14,
                        type: 3,
                        organizeid: $("#OrganizeId").attr('data-value'),
                        data: data
                    };

                }; break;
                case 4: {
                    var data = [{ id: "RepairedMemo", text: "", value: "" }];
                    options = {
                        category: 3,
                        type: 0,
                        organizeid: $("#OrganizeId").attr('data-value'),
                        itemId: 'RepairedMemo',
                        data: data
                    };
                }; break;
                case 5: {//报修人
                    var _type = 1;
                    if ($("#Range").attr("data-value") == 2) { _type = 3; }
                    var data = [{ id: "RepairMan", text: "", value: "" }, { id: "TellPhone", text: "", value: "" }];
                    options = {
                        category: 3,
                        type: _type,
                        organizeid: $("#OrganizeId").attr('data-value'),
                        data: data
                    };
                }; break;
            }
            DataItemClick(JSON.stringify(options));
        }
    }
</script>


<div id="wrapper" style="background: #fff;">
    <div id="left-side">
        <ul>
            <li class="choose active">
                制单派单
            </li>
            <li class="pay">
                维修回访
            </li>
            <li class="wrap">
                业务日志
            </li>
            @*<li class="ship">
                    相关记录
                </li>*@
        </ul>
    </div>

    <div id="border">
        <div id="line" class="one"></div>
    </div>

    <div id="right-side" class="tab-content">
        <div id="first" class="tab-pane active">
            <div id="BaseInfo" style=" margin-right: 15px">
                <table class="form">
                    <tr>
                        <td class="formTitle">所属机构<font face="宋体">*</font></td>
                        <td class="formValue">
                            <div id="OrganizeId" type="select" class="ui-select BaseClass" isvalid="yes" checkexpession="NotNull"></div>
                        </td>
                        <th class="formTitle">单据编号<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="Code" type="text" onblur="$.ExistField(this.id,'../../PropertyManage/CS_Decorate/ExistCode')" class="form-control BaseClass" placeholder="系统已启用自动编号" isvalid="yes" />
                        </td>
                        <th class="formTitle">单据日期<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="Date" type="text" class="form-control input-wdatepicker BaseClass" placeholder="请输入单据日期" value="@LeSoft.Util.Time.GetToday("yyyy-MM-dd HH:mm:ss")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">维修范围<font face="宋体">*</font></th>
                        <td class="formValue">
                            <div id="Range" type="selectTree" class="ui-select BaseClass" isvalid="yes" checkexpession="NotNull"></div>
                        </td>
                        <th class="formTitle">维修种类<font face="宋体">*</font></th>
                        <td class="formValue">
                            <div id="Kind" type="selectTree" class="ui-select BaseClass" isvalid="yes" checkexpession="NotNull"></div>
                        </td>
                        <th class="formTitle">维修专业<font face="宋体">*</font></th>
                        <td class="formValue">
                            <div id="Major" type="selectTree" class="ui-select BaseClass"></div>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">维修地点<font face="宋体">*</font></th>
                        <td class="formValue" colspan="3">
                            <div class="input-group" style="width: 100%;">
                                <input id="PStructId" type="text" class="form-control BaseClass" isvalid="yes" checkexpession="NotNull">
                                <span class="input-group-btn">
                                    <a onclick="DataItemSelect(1,this)" class="form-control BaseClass" style="cursor: pointer"><i class="fa fa fa-book" style=" font-size: 20px; padding-right: 5px; padding-top: 3px; color: gray"></i></a>
                                </span>
                            </div>
                        </td>
                        <th class="formTitle">业户名称<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="CustomerId" type="text" class="form-control BaseClass" isvalid="yes" checkexpession="NotNull" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">报修人<font face="宋体">*</font></th>
                        <td class="formValue">
                            <div class="input-group" style="width: 100%;">
                                <input id="RepairMan" type="text" class="form-control BaseClass" isvalid="yes" checkexpession="NotNull" />
                                <span class="input-group-btn BaseClass">
                                    <a onclick="DataItemSelect(5,this)" class="form-control BaseClass" style="cursor: pointer"><i class="fa fa fa-book" style=" font-size: 20px; padding-right: 5px; padding-top: 3px; color: gray;"></i></a>
                                </span>
                            </div>
                        </td>
                        <th class="formTitle">联系电话<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="TellPhone" type="text" class="form-control BaseClass" isvalid="yes" checkexpession="NotNull" />
                        </td>
                        <th class="formTitle">报修方式<font face="宋体">*</font></th>
                        <td class="formValue">
                            <div id="RepairWay" type="selectTree" class="ui-select BaseClass" isvalid="yes" checkexpession="NotNull"></div>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" valign="top" style="padding-top: 4px;">
                            报修内容<font face="宋体">*</font>
                        </th>
                        <td class="formValue" colspan="5">
                            <textarea id="RepairContent" class="form-control BaseClass" style="height: 50px;" isvalid="yes" checkexpession="NotNull"></textarea>
                        </td>

                    </tr>
                    <tr>
                        <th class="formTitle"></th>
                        <td class="formValue">
                            @*<div id="IsSubscribe" type="selectTree" class="ui-select"></div>*@
                            <input id="IsSubscribe" type="checkbox" class="BaseClass" /> 是否预约
                        </td>
                        <th class="formTitle" hidden>预约维修时间</th>
                        <td class="formValue" hidden>
                            <input id="SubscribeDate" type="text" class="form-control input-wdatepicker BaseClass" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle"></th>
                        <td class="formValue"></td>
                    </tr>
                    <tr>
                        <th class="formTitle" valign="top" style="padding-top: 4px;">
                            备注
                        </th>
                        <td class="formValue" colspan="5">
                            <textarea id="Memo" class="form-control BaseClass" style="height: 50px;"></textarea>
                        </td>
                    </tr>
                    @*<tr>
                            <th class="formTitle">是否提前提醒</th>
                            <td class="formValue">
                                <div id="IsAdvanceNote" type="selectTree" class="ui-select"></div>
                            </td>
                            <th class="formTitle">提前提醒小时数</th>
                            <td class="formValue">
                                <input id="AdvanceNoteHours" type="text" class="form-control" />
                            </td>
                        </tr>*@
                    <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr>
                        <td colspan="6">
                            <div class="box" style="    height: 100px;">
                                <img style="position: relative; float: left; width: 60px; height: 60px;" src="~/Content/images/icon_app_add.png" />
                                <input id="fileImage1" type="file" size="30" onchange=" UploadFile(1)" name="fileselect[]" accept="image/png,image/gif,image/jpeg" multiple style="position: absolute; width: 60px; height: 60px; opacity: 0;" />
                                <div id="preview" class="IMG1" style=" margin-left: 13px;">
                                </div>
                                <div class="photo-mask"></div>
                                <div class="photo-panel">
                                    <div class="photo-div">
                                        <div class="photo-left">
                                            <div class="arrow-prv"></div>
                                        </div>
                                        <div class="photo-img">
                                            <div class="photo-bar">
                                                <div class="photo-close"></div>
                                            </div>
                                            <div class="photo-view-h">
                                                <img src="" />
                                            </div>
                                        </div>
                                        <div class="photo-right">
                                            <div class="arrow-next"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr style="background: #B1ddff;">
                        <th class="formTitle">完成状态:</th>
                        <td class="formValue">
                            <div id="State" type="selectTree" class="ui-select" disabled="disabled"></div>
                        </td>
                        <th class="formTitle">派工方式:</th>
                        <td class="formValue">
                            <div id="SendWay" type="selectTree" class="ui-select SendClass"></div>
                        </td>
                        <td colspan="2" align="center" hidden>
                            <a id="lr-print" hidden class="btn btn-success btn-xl" onclick=""><i class="fa fa-print"></i>&nbsp;打印单据</a>
                        </td>
                    </tr>
                    <tr hidden style="background: #B1ddff;" id="TrWay">
                        <th class="formTitle">维修方式:</th>
                        <td class="formValue">
                            <div id="RepairedWay" class="radio"><label><input name="RepairedWay" class="SendClass" type="radio" checked="checked" value="1" disabled />自修</label><label> <input name="RepairedWay" class="SendClass" type="radio" value="2" disabled />外派</label></div>
                        </td>
                        <th class="formTitle">派给:</th>
                        <td class="formValue">
                            <div class="input-group" style="width: 100%;">
                                <input id="Person" type="text" class="form-control SendClass">
                                <span class="input-group-btn SendClass">
                                    <a onclick="DataItemSelect(2,this)" class="form-control SendClass" style="cursor: pointer"><i class="fa fa fa-book SendClass" style=" font-size: 20px; padding-right: 5px; padding-top: 3px; color: gray"></i></a>
                                </span>
                            </div>
                        </td>
                        <th class="formTitle" hidden>发送消息通知:</th>
                        <td class="formValue" hidden>
                            <div id="IsSendMessage" class="radio"><label><input name="IsSendMessage" class="SendClass" type="radio" value="1" />发送</label><label> <input name="IsSendMessage" class="SendClass" type="radio" checked="checked" value="0" />不发送</label></div>
                        </td>
                    </tr>

                    <tr style=" height: 0px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr>
                        <th class="formTitle">派单人:</th>
                        <td class="formValue">
                            <input id="SendMan" disabled type="text" placeholder="请输入派单人" class="form-control completetr SendClass" />
                        </td>
                        <th class="formTitle">接单人:</th>
                        <td class="formValue">
                            <input id="ReceivedMan" disabled type="text" placeholder="请输入接单人" class="form-control completetr SendClass" />
                        </td>
                        <th class="formTitle">维修人:</th>
                        <td class="formValue">
                            <input id="RepairedMan" disabled type="text" placeholder="请输入维修人" class="form-control completetr SendClass" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">派单时间</th>
                        <td class="formValue">
                            <input id="SendDate" disabled type="text" placeholder="请输入派单时间" class="form-control input-wdatepicker completetr SendClass" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle">接单时间:</th>
                        <td class="formValue">
                            <input id="ReceivedDate" disabled type="text" placeholder="请输入接单时间" class="form-control completetr SendClass" onfocus="WdatePicker()" />
                        </td>
                    </tr>

                </table>
            </div>
        </div>
        <div id="second" class="tab-pane">
            <div id="ExpandInfo" style=" margin-right: 15px">
                <table class="form">
                    <tr class="completetr">
                        <th class="formTitle">
                            维修完成情况
                        </th>
                        <td class="formValue">
                            @*<textarea id="Description" disabled class="form-control completetr" style="height: 50px;"></textarea>*@
                            <div class="input-group" style="width: 100%;">
                                <input id="RepairedMemo" disabled type="text" class="form-control completetr" isvalid="yes" checkexpession="NotNull" />
                                <span class="input-group-btn">
                                    <a onclick="DataItemSelect(4,this)" class="form-control completetr" style="cursor: pointer"><i class="fa fa fa-book" style=" font-size: 20px; padding-right: 5px; padding-top: 3px; color: gray;"></i></a>
                                </span>
                            </div>
                        </td>
                        <th class="formTitle">客户满意度</th>
                        <td class="formValue">
                            <input id="CustomerLevel" disabled type="text" class="form-control completetr" />
                        </td>
                        <th class="formTitle">客户意见</th>
                        <td class="formValue">
                            <input id="CustomerInfo" disabled type="text" class="form-control completetr" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">维修到达时间</th>
                        <td class="formValue">
                            <input id="ArriveDate" disabled type="text" class="form-control input-wdatepicker completetr" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle">故障判断</th>
                        <td class="formValue" colspan="3">
                            <input id="FaultMemo" disabled type="text" class="form-control completetr" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">维修开始时间</th>
                        <td class="formValue">
                            <input id="BeginDate" disabled type="text" class="form-control input-wdatepicker completetr" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle">维修结束时间</th>
                        <td class="formValue">
                            <input id="EndDate" disabled type="text" class="form-control input-wdatepicker completetr" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle">维修时长(分钟)</th>
                        <td class="formValue">
                            <input id="Minutes" disabled type="text" class="form-control  completetr" />
                            <label style="color:red;">标准时长：20分钟</label>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" hidden>维修专业</th>
                        <td class="formValue" hidden>
                            <input hidden id="RepairedMajor" disabled type="text" class="form-control completetr " />
                        </td>
                        <th class="formTitle">维修分类</th>
                        <td class="formValue">
                            <input id="RepairedTypeName" disabled type="text" class="form-control  completetr" />
                        </td>
                        <th class="formTitle">维修项目</th>
                        <td class="formValue">
                            <input id="RepairedItemName" disabled type="text" class="form-control completetr" />
                        </td>
                    </tr>
                    <tr style=" height: 0px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    @*<tr>
                            <td colspan="6">
                                <div style="margin: 5px; margin-top: 0px; margin-bottom: 0px;">
                                    <table id="gridTable"></table>
                                    <style>
                                        .ui-jqgrid .ui-jqgrid-caption {
                                            text-align: right;
                                            padding-right: 5px;
                                            background-color: #F5F5F5;
                                        }
                                    </style>
                                </div>
                                <div style="position: absolute; top: 270px; left: 120px;">
                                    <a id="lr-add" class="btn btn-success btn-xs" onclick="btn_add_field()"><i class="fa fa-plus"></i>&nbsp;添加</a>
                                    <a id="lr-edit" class="btn btn-info btn-xs" onclick="btn_edit_field()"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
                                    <a id="lr-delete" class="btn btn-danger btn-xs" onclick="btn_delete_field()"><i class="fa fa-trash-o"></i>&nbsp;移除</a>
                                </div>
                              </td>
                        </tr>*@
                    <tr>
                        <th class="formTitle">
                            维修费用:
                        </th>
                        <td class="formValue" colspan="5">
                            <div class="input-group">
                                <span class="input-group-addon">人工费</span>
                                <input type="number" id="Labor" class="form-control completetr" style="width: 150px; height: 28px;" />
                                <span class="input-group-addon">+ 材料费</span>
                                <input type="number" id="Material" class="form-control completetr" style="width: 150px; height: 28px;" />
                                <span class="input-group-addon">+ 其他费</span>
                                <input type="number" id="Other" class="form-control completetr" style="width: 150px; height: 28px;" />
                                <span class="input-group-addon"> = </span>
                                <input type="number" id="Count" class="form-control completetr" style="width: 150px; height: 28px;" />

                            </div>
                            @*<div class="input-group" style="width: 100%;">
                                    人工费 <input type="text" class="form-control completetr" style="width: 150px; height: 28px;" />+材料费 <input type="text" class="form-control completetr" style="width: 150px; height: 28px;" />+其他费 <input class="form-control completetr" type="text" style="width: 150px; height: 28px;" />= <input class="form-control completetr" type="text" style="width: 150px; height: 28px;" />
                                </div>*@
                        </td>
                    </tr>
                    <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr>
                        <td colspan="6">
                            <div class="box" style="    height: 100px;">
                                <img style="position: relative; float: left; width: 60px; height: 60px;" src="~/Content/images/icon_app_add.png" />
                                <input id="fileImage2" type="file" disabled size="30" onchange="UploadFile(2)" name="fileselect[]" accept="image/png,image/gif,image/jpeg" multiple style="position: absolute; width: 60px; height: 60px; opacity: 0;" />
                                <div id="preview" class="IMG2" style=" margin-left: 13px;">
                                </div>
                                <div class="photo-mask"></div>
                                <div class="photo-panel">
                                    <div class="photo-div">
                                        <div class="photo-left">
                                            <div class="arrow-prv"></div>
                                        </div>
                                        <div class="photo-img">
                                            <div class="photo-bar">
                                                <div class="photo-close"></div>
                                            </div>
                                            <div class="photo-view-h">
                                                <img src="" />
                                            </div>
                                        </div>
                                        <div class="photo-right">
                                            <div class="arrow-next"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr style="background: #B1ddff;">
                        <th class="formTitle"></th>
                        <td class="formValue">
                            <input id="IsReturnBack" type="checkbox" /> 是否进行回访
                        </td>
                        <th class="formTitle">给回访人:</th>
                        <td class="formValue">
                            <div class="input-group" style="width: 100%;">
                                <input id="ReturnPerson" type="text" class="form-control returnclass">
                                <span class="input-group-btn">
                                    <a onclick="DataItemSelect(3,this)" class="form-control returnclass" style="cursor: pointer"><i class="fa fa fa-book" style=" font-size: 20px; padding-right: 5px; padding-top: 3px; color: gray"></i></a>
                                </span>
                            </div>
                        </td>
                        <th class="formTitle"></th>
                        <td class="formValue"> </td>
                    </tr>
                    <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                    <tr>
                        <th class="formTitle">回访/检验人:</th>
                        <td class="formValue">
                            <input id="ReturnBackName" type="text" class="form-control returnclass" />
                        </td>
                        <th class="formTitle">回访/检验时间:</th>
                        <td class="formValue">
                            <input id="ReturnBackDate" type="text" class="form-control input-wdatepicker returnclass" onfocus="WdatePicker()" />
                        </td>
                        <th class="formTitle">回访/检验方式</th>
                        <td class="formValue">
                            <input id="ReturnBackWay" type="text" class="form-control returnclass" />
                        </td>
                    </tr>
                    <tr>

                        <th class="formTitle" valign="top" style="padding-top: 4px;">
                            回访/检验情况:
                        </th>
                        <td class="formValue" colspan="5">
                            <textarea id="ReturnBackMemo" class="form-control returnclass" style="height: 50px;"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="third" class="tab-pane">
            <div class="gridPanel" style=" margin-right: 15px">
                <table id="gridTable_Operate"></table>
            </div>
        </div>

        @*<div id="fourth" class="tab-pane">

            </div>*@
    </div>
    <div class="form-button" id="wizard-actions" hidden>
        <a id="btn_save" class="btn  btn-success" onclick="AcceptClick();">确认</a>
        <a id="btn_submit" class="btn btn-danger" onclick="dialogClose()">关闭</a>
    </div>
    <script>

        $('.choose').click(function () {
            $('.choose').addClass('active');
            $('.pay').removeClass('active');
            $('.wrap').removeClass('active');
            $('.ship').removeClass('active');
            $('#line').addClass('one');
            $('#line').removeClass('two');
            $('#line').removeClass('three');
            $('#line').removeClass('four');
            $('#first').addClass('active');
            $('#second').removeClass('active');
            $('#third').removeClass('active');
            $('#fourth').removeClass('active');
            $("#right-side table").css("margin", "15px 0px");
        });
        $('.pay').click(function () {
            $('.pay').addClass('active');
            $('.choose').removeClass('active');
            $('.wrap').removeClass('active');
            $('.ship').removeClass('active');
            $('#line').addClass('two');
            $('#line').removeClass('one');
            $('#line').removeClass('three');
            $('#line').removeClass('four');
            $('#first').removeClass('active');
            $('#second').addClass('active');
            $('#third').removeClass('active');
            $('#fourth').removeClass('active');
            $("#right-side table").css("margin", "15px 0px");
        });
        $('.wrap').click(function () {
            $('.wrap').addClass('active');
            $('.pay').removeClass('active');
            $('.choose').removeClass('active');
            $('.ship').removeClass('active');
            $('#line').addClass('three');
            $('#line').removeClass('two');
            $('#line').removeClass('one');
            $('#line').removeClass('four');
            $('#first').removeClass('active');
            $('#second').removeClass('active');
            $('#third').addClass('active');
            $('#fourth').removeClass('active');
            $("#right-side table").css("margin", "0px");
            getOperateGrid();
        });
        $('.ship').click(function () {
            $('.ship').addClass('active');
            $('.pay').removeClass('active');
            $('.wrap').removeClass('active');
            $('.choose').removeClass('active');
            $('#line').addClass('four');
            $('#line').removeClass('two');
            $('#line').removeClass('three');
            $('#line').removeClass('one');
            $('#first').removeClass('active');
            $('#second').removeClass('active');
            $('#third').removeClass('active');
            $('#fourth').addClass('active');
            $("#right-side table").css("margin", "15px 0px");
        });


    </script>

</div>
